package classpath

import "io/ioutil"
import "path/filepath"

type DirEntry struct {
    absDir string
}

//创建DirEntry实例
func newDirEntry(path string) *DirEntry {
    //获得绝对路径
    absDir, err := filepath.Abs(path)
    if err != nil {
        panic(err)
    }
    return &DirEntry{absDir}
}

//加载DirEntry,读取class文件
func (self *DirEntry ) readClass(className string) ([]byte, Entry, error) {
    //绝对路径和class文件名拼成完整路径
    fileName := filepath.Join(self.absDir, className)

    //读取class文件内容
    data, err := ioutil.ReadFile(fileName)

    return data, self, err
}

//toString()方法
func (self *DirEntry) String() string {
    return self.absDir
}